Skip to content

Make Disposition an IntFlag so Stream.disposition setter accepts members#2257

Merged
WyattBlue merged 1 commit intoPyAV-Org:mainfrom
HotariTobu:fix/disposition-intflag
May 7, 2026
Merged

Make Disposition an IntFlag so Stream.disposition setter accepts members#2257
WyattBlue merged 1 commit intoPyAV-Org:mainfrom
HotariTobu:fix/disposition-intflag

Conversation

@HotariTobu
Copy link
Copy Markdown
Contributor

Closes #2256

Stream.disposition is typed as Disposition but the runtime setter (self.ptr.disposition = value, a C int field) calls int(value), which fails on plain Flag members because they are not int subclasses. Switching Disposition to IntFlag fixes the contract: members are int subclasses, so the conversion succeeds, and bitwise / membership semantics are unchanged.

# Before: TypeError
video.disposition = Disposition.attached_pic

# After: OK
video.disposition = Disposition.attached_pic

Both av/stream.py (runtime) and av/stream.pyi (stub) are updated for consistency.

Stream.disposition is typed as Disposition but the runtime setter
assigns to a C int field, calling int(value). Plain Flag members are
not int subclasses, so this raises TypeError. IntFlag members are int
subclasses; bitwise / membership semantics are preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@WyattBlue WyattBlue merged commit f9f0730 into PyAV-Org:main May 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stream.disposition setter rejects Disposition enum members at runtime (type/runtime contract mismatch)

2 participants